// import com.alibaba.druid.sql.ast.SQLObject;
// import com.alibaba.druid.sql.visitor.SQLASTVisitor;

// import java.util.Collections;
// import java.util.std::shared_pre<std::list;

#include "SQLBigIntExpr.h"
#include "../SQLObject.h"
#include "../../visitor/SQLASTVisitor.h"

SQLBigIntExpr::SQLBigIntExpr()
{
}

SQLBigIntExpr::SQLBigIntExpr(long value)
    : SQLNumericLiteralExpr()
{

  this->value = value;
}

SQLBigIntExpr::SQLBigIntExpr(string_ptr value)
    : SQLNumericLiteralExpr()
{
  this->value = atol(value->c_str());
}

SQLObject_ptr SQLBigIntExpr::clone()
{
  // return new SQLBigIntExpr(value);
  SQLObject_ptr clone_tmp = std::shared_ptr<SQLBigIntExpr>(new SQLBigIntExpr(value));
  std::shared_ptr<SQLBigIntExpr> clone_res = std::dynamic_pointer_cast<SQLBigIntExpr>(clone_tmp);

  return clone_res;
}

//@Override
SQLObject_list_ptr SQLBigIntExpr::getChildren()
{
  return std::make_shared<std::list<SQLObject_ptr>>();
}

//@Override
double SQLBigIntExpr::getNumber()
{
  return value;
}

//@Override
long SQLBigIntExpr::getValue()
{
  return value;
}

void SQLBigIntExpr::setValue(long value)
{
  this->value = value;
}

void SQLBigIntExpr::accept0(SQLASTVisitor_ptr visitor)
{
  visitor->visit(SharedObject(SQLBigIntExpr));

  visitor->endVisit(SharedObject(SQLBigIntExpr));
}

//@Override
int SQLBigIntExpr::hashCode()
{
  int prime = 31;
  int result = 1;
  // result = prime * result + ((value == null) ? 0 : value.hashCode());
  result = prime * result + value;
  return result;
}

//@Override
bool SQLBigIntExpr::equals(Object_ptr obj)
{
  if (this == obj.get())
  {
    return true;
  }
  if (obj == nullptr)
  {
    return false;
  }
  if (getClass() != obj->getClass())
  {
    return false;
  }
  std::shared_ptr<SQLBigIntExpr> other = std::dynamic_pointer_cast<SQLBigIntExpr>(obj);
  // if (value == null) {
  //     if (other.value != null) {
  //         return BOOL::FALSE;
  //     }
  // } else
  if (value != other->value)
  {
    return false;
  }
  return true;
}

//@Override
void SQLBigIntExpr::setNumber(double number)
{
  // if (number == null) {
  //     this->setValue(null);
  //     return;
  // }

  this->setValue(((long)number));
}
